Methods and Sytems for Reducing Churn in a Caching Device

ABSTRACT

A storage device includes a flash memory-based cache for a hard disk-based storage device and a controller that is configured to limit the rate of cache updates through a variety of mechanisms, including determinations that the data is not likely to be read back from the storage device within a time period that justifies its storage in the cache, compressing data prior to its storage in the cache, precluding storage of sequentially-accessed data in the cache, and/or throttling storage of data to the cache within predetermined write periods and/or according to user instruction.

RELATED APPLICATIONS

This application is a Continuation of U.S. application Ser. No.14/953,970 filed on Nov. 30, 2015, which is a Continuation of U.S.application Ser. No. 14/473,992 filed on Aug. 29, 2014 (now issued asU.S. Pat. No. 9,235,506), which is a Continuation of U.S. applicationSer. No. 12/836,520 filed on Jul. 14, 2010 (now issued as U.S. Pat. No.9,213,628), all of which are incorporated herein by reference.

FIELD OF THE INVENTION

The present invention relates to the use of a flash memory-based cachefor a hard disk-based storage device and, in particular, to techniquesfor limiting the rate of cache updates, also known as “churn”, in such adevice.

BACKGROUND

Hard disk drives (HDD), or simply hard disks, are found in manycomputers and dedicated storage appliances. Hard disks can offersignificant available storage space (e.g., on the order of terabytes),but the speed at which data can be read from such devices is limited byphysical properties such as the speed at which the disk(s) rotate, andthe time required for the read head to be maneuvered into the correctposition to read the requested data information elements (the so-calledseek time).

Solid state storage devices, typically those that employ flash memory asthe storage medium, offer improved read times compared to hard disks, inpart because there are no moving parts associated with such a device.Write times, however, are often worse than those associated with harddisks because flash memory can only be written in relatively large“erase block” sizes (e.g., typically 128 KB-512 KB), which must beerased and rewritten in their entirety even if only a small amount ofdata within the block needs to be updated.

Today, storage devices that employ both flash memory and hard disks arebeing marketed. In some instances, the flash memory portion of thesedevices is being used as a cache for data stored on the hard disk. Acache is generally regarded to be a storage area that holds a subset ofthe data stored on a larger, generally slower, storage medium. The flashmemory provides lower latency and serves higher numbers of requests persecond than the hard disks and so data stored in the cache portion ofthe storage device can be delivered more rapidly than if the data had tobe accessed from the hard disks. However, updating the cache requireswriting to the flash memory, which has drawbacks. As noted above, theflash memory is comparatively slow to write, especially when it must bewritten randomly to replace the “coldest” (e.g., least frequentlyaccessed or least likely to be needed) data in the cache. Hence, writesto a flash-based cache can slow down concurrent reads from the storagedevice, thus reducing the benefit of caching. In addition, flash memoryhas limited write endurance. Typically, flash blocks wear out after10,000 to 100,000 writes.

SUMMARY OF THE INVENTION

Recognizing that issues such as the comparatively slow write times andlimited write endurance of flash memories provide an incentive to reducethe rate of updates to a flash-based cache, the present inventors havedeveloped methods and systems for limiting the rate of cache updates ina storage device having a flash memory-based cache and a disk-basedstorage unit.

For example, in some instances, a controller of the storage deviceselectively writes-through data received at the storage device to boththe cache and the disk-based storage unit if the controller determinesthe data is likely to be read back non-sequentially from the storagedevice within a time period that justifies its storage in the cache;otherwise, if a previous version of the data exists in the cache, thecontroller writes the data only to the disk-based storage unit andinvalidates the previous version of the data in the cache; else, if noprevious version of the data exists in the cache, the controller writesthe data only to the disk-based storage unit. The controller maydetermine whether or not the data is likely to be read back from thestorage device within the time period that justifies its storage in thecache according to statistics concerning past accesses that have beengathered by the controller.

If the controller does determine that the data is not likely to be readback within the time period that justifies its storage in the cache, andthe previous version of the data exists in the cache, then thecontroller may invalidate the previous version of the data in the cacheby storing an address of the previous version of the data that exists inthe cache in an invalidate buffer of a non-volatile RAM (NVRAM) of thestorage device. Such invalidations of previously stored versions of datawritten to the cache stored in the invalidate buffer may be committed tothe cache when the invalidate buffer is filled.

Alternatively, or in addition to the above, data to be stored in thestorage device may be compressed prior to being written to the flashmemory-based cache. Such compression may produce variable sized blocksof data, which are subsequently written to the cache.

In still further examples, data to be stored in a storage device may beinitially written to a flash memory-based cache and a disk-based storageunit of the storage device, however, if the amount of data being writtensequentially exceeds a predetermined threshold, a controller may stopwriting data to the cache and write the data only to the disk-basedstorage unit.

In still other examples, cache updates may be throttled when a storagedevice controller determines that a threshold number of permitted writesfor a given write period has been reached and refuses further writes toa cache of the storage device for the duration of that write period.Each subject write period may be a period of fixed interval.Alternatively, or in addition, the controller may throttle updates tothe cache in accordance with user input concerning whether or not thedata is to be cached.

These and further embodiments of the present invention are discussedbelow.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example, and notlimitation, in the figures of the accompanying drawings in which:

FIG. 1A illustrates an example of a storage device in which embodimentsof the present invention may be instantiated;

FIG. 1B illustrates a further example of a storage device in whichembodiments of the present invention may be instantiated; and

FIG. 2 illustrates an example of a selective write-through operation ina storage device configured in accordance with an embodiment of thepresent invention.

DETAILED DESCRIPTION

Recognizing the advantages afforded by incorporating both a flashmemory-based cache and one or more hard disks in a common storagedevice, the present inventors have devised such a storage device inwhich a controller (or cache management module) is configured to limitthe rate of cache updates, a.k.a. churn. In accordance with the presentinvention, while the controller is configured to permit some “hot”(e.g., frequently accessed or likely to be needed) data to be stored inthe cache, not all such data is permitted to be so stored. This avoidswasteful, even counter-productive situations which may arise when allhot data is stored in a flash-based cache. The techniques for limitingchurn that are discussed herein may be applied in combination with oneanother within a single storage device, or they may be appliedindependently of one another.

FIG. 1A shows an example of a storage device 100 in which embodiments ofthe present invention may be instantiated. Storage device 100 includesone or more hard disks 102 and a flash memory-based cache 104. The disksand/or the flash memory cache may be included in an integrated storagedevice 100 or attached as separate devices (see e.g., the embodimentillustrated in FIG. 1B). The disks 102 and flash memory-based cache 104are under the control of a controller 106A, which may include firmwarethat instantiates the techniques for minimizing churn discussed herein.Storage device 100 is accessible (e.g., to applications running on ahost machine) via a host interface 108, which may, in general, conformto specifications for disk-based storage devices common in the industry(e.g., an advanced host controller interface that uses a serial ATA bus,a small computer system interface (SCSI) or variants thereof, or anInternet protocol-based protocol, etc.). Except where particularprotocols are called out, the systems and methods disclosed herein donot depend on the particular protocol being used and storage devicesconfigured in accordance with the present invention can be configured tooperate correctly with all of them.

Controller 106A is, in some embodiments of the invention, configuredsuch that cache management operations include any or all of: compressingdata before it is committed to the flash memory-based cache, avoidingcaching of sequentially-accessed data (i.e., data that is likely to beread back sequentially), selective write through caching, and throttlingcache updates based on the amount of data previously written to thecache. Each of these techniques is discussed in greater detail below. Anon-volatile random access memory (NVRAM) 110 is accessible tocontroller 106A and may be used to store invalidation information, asdiscussed below.

FIG. 1B illustrates an alternative example of a storage device 100′,which includes a backend storage device 116, having a hard disk, and acaching device 112, having a flash memory-based cache, communicativelycoupled with one another by an interface 114. In this example, each ofthe backend storage device and the caching device employ a controller,106B and 106C, respectively. Controller 106B is configured to managestoring operations involving hard disk 102, while controller 106C isconfigured to manage storage operations for the storage device 100′ inthe manner described above for controller 106A. Thus, storage operationsinvolving the hard disk and the flash memory-based cache may bedistributed across multiple physical devices, but managed in accordancewith the present invention.

Before describing the techniques for minimizing churn in detail, it ishelpful to define some terms that will appear in this description. Forexample, when we use the term cache update, we mean an update thatoccurs either on a read miss or a write. A read miss occurs when thedata requested in a read is not present in the cache and must be fetchedfrom the backing medium. A write occurs when data is written to thecache. Such writes may be governed by any of several policies thatdictate the manner or time at which data written to the storage deviceis written to the cache and the backing storage medium (e.g., the harddisks). Appropriate use of a cache write policy in accordance with thepresent invention is useful in reducing churn arising from writes.

In a “write-through” cache, every write to the storage device causes asynchronous write to the cache and the backing storage medium. Thistechnique imposes a high write rate on cache, hence it is notwell-suited for flash memory-based cache which has limited writeendurance.

In a write-back cache, writes are not immediately mirrored to thebacking storage medium. Instead, data is buffered in the cache for aperiod of time and written back to storage later, for example when somedata must be evicted from the cache to make space for new data. For adevice incorporating a flash memory-based cache for data stored on disk,this technique has two drawbacks. First, it requires the cache to beloss-less, since the cache includes dirty data that is not yet stored ondisk. Second, it imposes a high write rate because all writes must go tothe cache. In practice, flash memory is known to be unreliable (and socannot be guaranteed to be loss-less) and, as indicated above, haslimited write endurance.

In contrast to write-through and write-back schemes, in a“write-invalidate” cache, written data is not entered in the cache atall and is stored directly on backing storage medium. New data is put incache only on read misses, never on writes. If an older version of thewritten data is present in the cache (because of a prior read), thatolder version is invalidated. This technique does not impose a highwrite rate on flash—at least not because of data writes—however, it hasthe drawback that the first data read after a data write misses in thecache.

In one embodiment, the present invention provides a “selective writethrough” cache. In this scheme, which applies to cache updates on writesbut not on read misses, data that is likely to be read back soon, and ina non-sequential fashion, is entered in the cache. Other data is merelyinvalidated in the cache (if its older version exists in the cache),using an invalidate buffer in the NVRAM as an aid. As discussed furtherbelow, it is desirable to cache only that data which is likely to beread back non-sequentially, inasmuch as hard disks provide roughly equalperformance as flash for sequentially-accessed data. Therefore, theselective write-through process is applied in cases of writes involvingdata likely to be read back soon, and in a non-sequential fashion. FIG.2 illustrates an example of such a selective write-through operation200.

Writes 202 that are presented to a storage device controller (such ascontroller 106A or controller 106B) are examined to determine whetherthe data involved in the write is data that should be cached. Forexample, the controller determines whether the data is likely to be readback non-sequentially and within a time period that justifies itsstorage in the cache. This may be done based on statistics concerningpast accesses that have been gathered by the storage device controllerand/or information concerning the type of data involved in the write(e.g., log data is rarely read back, if ever), etc. If the storagedevice controller determines that the data is not a good candidate forcaching (i.e., is sequentially-accessed data, is not likely to be readback within this predetermined time period, is of a type not likely tobe read back, etc.), then the address of that data (if a copy thereofalready exists in the cache) 206 is stored, persistently andefficiently, in an invalidate buffer 208 in the NVRAM 110. If no copy ofthe write data exists in the cache, no address information need bestored in the invalidate buffer. In either case, the data itself is notwritten to the cache, but it is written to the backing storage media(e.g., hard disk 102).

The NVRAM is generally smaller (e.g., on the order of a few GB) than theflash based cache (which is, e.g., typically on the order of hundreds ofGB), but it can withstand significant churn because it is RAM-based.Since invalidations contain only data addresses, not the data itself,they are relatively small data objects and can be stored efficiently inthe NVRAM. In the unlikely case that the NVRAM is lost, the flash cachecan be purged to ensure that the cache does not serve stale data.Because the data exists on the backing storage media, it is not lost insuch an event.

Returning to FIG. 2, if the data storage device controller determinesthat the data is likely to be read back relatively soon (there need notbe a defined time limit and the relative timeframe for likely read backmay be based on observed statistics of the controller), then that data210 is stored in the flash cache 212 and synchronously written to thebacking storage medium (e.g., hard disk 102). Hence the write-throughnature of this write policy.

Eventually, the NVRAM invalidate buffer may become filled 214. When thisoccurs, the invalidations are applied to the flash cache 216. Thisinvolves a write, but overall the number of writes is reduced from thatwhich would otherwise be the case and so overall churn is reduced.

While the above-described selective write-through policy only applies tocache updates involving writes, the remaining churn-avoidance techniquesdiscussed below may be applied to any form of cache update, e.g., bothread misses and writes (and, where used, cache prefetches as well). Forexample, embodiments of the present invention may make use of datacompression when dealing with cache updates. In particular, dataassociated with a cache update is compressed before being stored in theflash memory-based cache. The compression may be applied by a storagedevice controller) such as controller 106A or 106C, or other processingunit of the subject storage device. Using data compression in thismanner has at least two advantages: First, data compression increasesthe effective size of the cache, thereby allowing for increased hitrates (i.e., increased likelihoods that requested data will be found inthe cache). Second, by reducing the amount of data written to the flashmemory, the data compression extends the life of the flash memory (i.e.,since more data can be accommodated in the cache, fewer writes arerequired per unit of data to be stored, hence, the limited endurance ofthe flash memory is not tested as quickly as might otherwise be thecase).

Compressing data prior to storage in flash memory is not straightforwardbecause it results in variable-size blocks. Typically, flash memory canonly be written in relatively large, fixed block sizes (e.g., typically128 KB-512 KB), which must be erased and rewritten in their entiretyeven if only a small amount of data within the block needs to beupdated. However, the present invention accommodates the use of variablesized blocks by using a “log structured” cache.

In a log-structured file system, the main data structure on the storagemedium is a sequentially written log. New data, including modificationsto existing blocks, is written to the end of the log. In accordance withthe present techniques, the log is compressed as it is written to theflash cache. In this scheme, no blocks are overwritten, hence, it doesnot matter if new data does not compress to blocks of the same size asexisting data. Because blocks are written sequentially, the compressedblocks can be packed tightly together in the flash memory, eliminatingfragmentation. Some metadata concerning the location of where thecompressed blocks are stored in the flash cache must also be kept. Insome instances, this metadata may be stored in the NVRAM for efficiency.

In one embodiment of the present invention, a g-zip style compression isemployed, however, any compression scheme may be used. In addition, thecontroller is configured to perform “garbage collection” to ensure thatlarge segments of the flash array are kept available for the contiguouswrites required for proper coalescing of the variable blocks.

As mentioned above, in embodiments of the present invention thecontroller is configured to avoid caching sequentially-accessed data.For large sequential accesses (say, larger than 1 MB), hard disksprovide performance that is approximately similar to that offered byflash memory (e.g., on the order of 100-200 MB/s). Therefore, there islittle incentive to enter such data in the flash memory-based cache. Thestorage device controller is therefore configured with variousheuristics to predict sequentially and to avoid cachingsequentially-accessed data.

For example, the controller may be configured to recognize that if somedata is currently being accessed sequentially, that same data is likelyto be accessed sequentially in the future. Accordingly, the controllermay start by writing data to the cache, monitoring the size of thewrite. If the sequential write grows beyond a certain threshold size(e.g., on the order of 1 MB or so), the controller may determine theassociated data to be sequentially-accessed data and to stop writing thedata to the flash memory-based cache. Such data would, instead, bewritten only to the disk(s).

Still further embodiments of the present invention provide forthrottling cache updates based on the amount of data written previously.As noted above, flash memory has limited endurance for writes. On theother hand, users expect a certain amount of life for storageappliances, e.g., 5 years. To increase the likelihood that the flashmemory-based cache will survive for its intended lifetime, the storagedevice controller is configured to throttle updates to the cache to aspecified number over a defined write period. The threshold number ofpermitted writes per write period can be updated periodically, forexample, each write period, to ensure that the cache is being managedefficiently. For example, if it is the case that for several writeperiods the threshold number of writes was not being met, then thecontroller may distribute the excess capacity across the remaininglifetime of the storage device so as not to unnecessarily prevent use ofthe cache during write periods of increased write activity.

Throttling of cache updates in this fashion may be accomplished asfollows: The expected lifetime of the storage device is divided intoshorter but convenient periods of fixed interval, say one week (“writeperiods”). (Selecting intervals that are too short, such as one minutemight constrain update rates unnecessarily.) The controller isconfigured to keep track of the number of writes made to the cache sincebeing placed in service and the accumulated in-service time for thestorage device (e.g., as a measure of its expended, expected lifetime).Then, the controller determines the number of permitted writes per writeperiod by dividing the number of further writes that can be tolerated(e.g., determined by subtracting the number of writes to date from thetotal number of writes that can be tolerated) into the number of writeperiods left in the expected service lifetime for the storage device.The result is the threshold number of permitted writes per write period.

Over the succeeding write period, the controller monitors the number ofwrites to the flash cache and allows, at most, a number of writes equalto the threshold number of permitted writes. Any further attemptedupdates to the cache during this write period are refused. As indicatedabove, in the case of writes this means invalidating data instead ofwriting through.

Still a further technique for reducing churn in a flash memory-basedcache in accordance with embodiments of the invention is to rely on userinput concerning the nature of data being written to the storage device.That is, in some instances a user may indicate that a certain datasetshould not be cached (e.g., by signaling the storage device controllerthrough a management interface or other means, or by including metadatawith the dataset being stored, which metadata can be parsed by thecontroller to determine its data type). By way of example, a user mayindicate that a dataset comprise of a database log should not be cachedbecause the log is generally not read, and, when it is read, it is readsequentially.

In various embodiments of the invention, the foregoing techniques forreducing churn may be applied individually or in any combination withone another. Accordingly, storage device controllers may be configuredto implement any or all of the techniques discussed herein, for exampleaccording to user configuration instructions when placing a storagedevice in service or otherwise managing the device. In some instances,the storage device controller may be configured to apply different onesof the above-described techniques at different times (e.g., according tothe number of writes to the flash cache in the aggregate or over a givenperiod of time, time of day, day of week/month, etc.). The techniquesare not mutually exclusive of one another, nor do they depend on oneanother for their instantiation in a storage device.

Thus, storage devices that incorporate controllers or cache managementmodules configured to limit the rate of cache updates, or churn, havebeen described. As should be evident from the foregoing description,various embodiments of the present invention may be implemented with theaid of computer-implemented processes or methods (a.k.a. programs orroutines) that may be rendered in any computer language. Such processesare meant to encompass any series of logical steps performed in asequence to accomplish a given purpose. The operations of the storagedevice controller were discussed in terms of algorithms and operationson data within a memory or buffer and these algorithms and operationswere intended to convey the nature of computer programs sufficient todirect the operations of the storage device controller to perform thedesired tasks. Hence, it should be appreciated that the use of termssuch as “processing”, “computing”, “calculating”, “determining”,“displaying” or the like, refer to the action and processes of thestorage device controller described herein, or an appropriatelyprogrammed computer system, or similar electronic computing device, forexample that manipulates and transforms data. The computer program thatembodies these processes may be stored in a computer readable storagemedium, such as, but not limited to, any type of disk including floppydisks, optical disks, compact disk read only memories (CD-ROMs), andmagnetic-optical disks, read-only memories (ROMs), flash drives, randomaccess memories (RAMs), erasable programmable read only memories(EPROMs), electrically erasable programmable read only memories(EEPROMs), flash memories, other forms of magnetic or optical storagemedia, or any type of media suitable for storing electronicinstructions, and accessible to the storage device controller.

1-20. (canceled)
 21. A method for a storage device having a cachingdevice and a backend storage device, the method comprising: receivingdata at the storage device, the data including sequentially-accesseddata; and performing, by a controller of the storage device, a selectivecaching of the sequentially-accessed data, wherein the selective cachingcomprises: if the sequentially-accessed data can be read from thebackend storage device at a substantially similar data rate as from thecaching device, writing the sequentially-accessed data only to thebackend storage device so as to reduce the amount of data written to thecaching device; and if the sequentially-accessed data cannot be readfrom the backend storage device at a substantially similar data rate asfrom the caching device, writing the sequentially-accessed data to boththe caching device and the backend storage device.
 22. The method ofclaim 21, wherein a size of the sequentially-accessed data is greaterthan 1 megabyte (MB).
 23. The method of claim 21, wherein the selectivecaching of the sequentially-accessed data comprises a selectivewrite-through caching of the sequentially-accessed data.
 24. The methodof claim 21, wherein the selective caching of the sequentially-accesseddata is applied on writes but is not applied on read misses.
 25. Astorage device, comprising a caching device, a backend storage deviceand a controller, the controller (i) communicatively coupled to thecaching device and the backend storage device; and (ii) configured to:receive data at the storage device, the data includingsequentially-accessed data; and perform a selective caching of thesequentially-accessed data, wherein the selective caching comprises: ifthe sequentially-accessed data can be read from the backend storagedevice at a substantially similar data rate as from the caching device,writing the sequentially-accessed data only to the backend storagedevice so as to reduce the amount of data written to the caching device;and if the sequentially-accessed data cannot be read from the backendstorage device at a substantially similar data rate as from the cachingdevice, writing the sequentially-accessed data to both the cachingdevice and the backend storage device.
 26. The storage device of claim25, wherein a size of the sequentially-accessed data is greater than 1megabyte (MB).
 27. A non-transitory computer-readable storage mediumcomprising software instructions that, when executed by a controller ofa storage device, cause the controller to: receive data at the storagedevice, the data including sequentially-accessed data; and perform aselective caching of the sequentially-accessed data, wherein theselective caching comprises: if the sequentially-accessed data can beread from a backend storage device of the storage device at asubstantially similar data rate as from a caching device of the storagedevice, writing the sequentially-accessed data only to the backendstorage device so as to reduce the amount of data written to the cachingdevice; and if the sequentially-accessed data cannot be read from thebackend storage device at a substantially similar data rate as from thecaching device, writing the sequentially-accessed data to both thecaching device and the backend storage device.
 28. The non-transitorycomputer-readable storage medium of claim 27, wherein a size of thesequentially-accessed data is greater than 1 megabyte (MB).